When a socket connection (an endpoint for communication between two machines) is instantiated, such as a Remote Method Invocation (RMI) or an Object Request Broker (ORB) connection, the socket connection may be cached for reuse due to the fact that it is an expensive process in creating a socket connection in terms of time and resources.
Whenever a socket connection is cached though, it reduced the total available file descriptors (an indicator for accessing a file/socket) to be used by the applications of the system as every end point of the socket connection creates and maintains a socket. If a substantial number of socket connections are cached, and as a result, a substantial number of file descriptors are used, then there may not be any file descriptors available for the applications. For example, if the maximum file descriptor limit is set to 1,024, and the number of file descriptors used to refer to the cached socket connections reaches 1,024, then there will not be any file descriptors available for the applications.
In an attempt to ensure that there will be file descriptors available for the applications, a time out period for which the socket connections are maintained in the cache may be implemented. When the time out period is reached, the socket connections are cleared from the cache, and their file descriptors become available. However, the time period may be set too low thereby clearing the cache pre-maturely defeating the purpose of having a cache. However, if the time period is set too high, then too many socket connections may be cached resulting in few, if any, available file descriptors for the applications.
Another attempt to ensure that there will be file descriptors available for the applications is to use a monitoring tool to monitor file descriptor leaks, referring to the situation when memory is consumed for file descriptors but is unable to be released back to the operating system. However, such a technique does not address the situation of having file descriptors created when socket connections are cached.
As a result, there is not currently an effective technique in caching socket connections while ensuring that there are file descriptors available for the applications in the system.